Skip to content

fix(uv): respect uv.tool settings in pyproject.toml#3811

Merged
rickeylev merged 10 commits into
bazel-contrib:mainfrom
aignas:aignas.fix.uv_tool_settings
Jun 9, 2026
Merged

fix(uv): respect uv.tool settings in pyproject.toml#3811
rickeylev merged 10 commits into
bazel-contrib:mainfrom
aignas:aignas.fix.uv_tool_settings

Conversation

@aignas

@aignas aignas commented Jun 6, 2026

Copy link
Copy Markdown
Collaborator

With this we auto-detect the location of the project file based on
where the first pyproject.toml file is located. Whilst this may work
for majority of the cases there could be a case where the user wants
to leverage the workspaces, we iterate through all pyproject.toml
files and choose the one with the shortest directory path. If this
does not work, we you can just override it manually.

Along the way, give some advice to agents for handling flakey CI and
pushing changes to PRs.

Fixes #3807

With this we auto-detect the location of the project file based on
where the first pyproject.toml file is located. Whilst this may work
for majority of the cases there could be a case where the user wants
to leverage the workspaces, we iterate through all pyproject.toml
files and choose the one with the shortest directory path. If this
does not work, we you can just override it manually.

Fixes bazel-contrib#3807
@aignas aignas requested a review from rickeylev as a code owner June 6, 2026 06:22

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces automatic detection of the project directory for the lock rule when a pyproject.toml file is present in the source files, passing the --project parameter to uv pip compile. It also adds a project attribute to override this behavior, updates documentation, and includes comprehensive tests for workspaces and single projects. A critical bug was identified in the auto-detection logic where a root-level pyproject.toml (with an empty directory path "") would be treated as falsy, causing it to be incorrectly overwritten or falling back to the package directory; a fix was suggested to explicitly check against None.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread python/uv/private/lock.bzl Outdated
Comment thread python/uv/private/lock.bzl Outdated
Comment thread python/uv/private/lock.bzl Outdated
Comment thread tests/uv/lock/pyproject_toml/BUILD.bazel Outdated
Skip auto-detection of pyproject.toml when the project attribute is
already set to prevent unnecessary traversal, and remove the boilerplate
Bazel copyright header from tests/uv/lock/pyproject_toml/BUILD.bazel.
Comment thread python/uv/private/lock.bzl Outdated
Comment thread tests/uv/lock/pyproject_toml/BUILD.bazel Outdated
rickeylev added 4 commits June 8, 2026 05:49
Explicitly check against None instead of relying on falsiness when
autodetecting project paths so that root-level pyproject.toml files
(with dirname "") are correctly respected and not overwritten.
Passing --project "" is an invalid state for uv. Omit passing --project
entirely when the value is empty, and update flag insertion to use the
args.add_all([project], before_each = "--project") style.
@rickeylev rickeylev enabled auto-merge June 8, 2026 05:56
@rickeylev

Copy link
Copy Markdown
Collaborator

last error: CI says lock file on windows differs, but doesn't give details about the diff?

rickeylev added 2 commits June 8, 2026 15:27
Skip Windows execution for the tests/uv/lock/workspaces:requirements_test
target to bypass an apparent diff_test limitation in CI, and update AGENTS.md
to clarify that tests/support/ contains testing helpers.
@rickeylev rickeylev added this pull request to the merge queue Jun 9, 2026
@rickeylev rickeylev removed this pull request from the merge queue due to a manual request Jun 9, 2026
Document CI flakiness and recommend deploying a background monitoring agent to
track PR builds and retry transient network failures (or configure bazelrc retry
flags as a fallback).
@rickeylev rickeylev enabled auto-merge June 9, 2026 05:49
@rickeylev rickeylev added this pull request to the merge queue Jun 9, 2026
Merged via the queue into bazel-contrib:main with commit c0fef46 Jun 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv settings are ignored in pyproject.toml

2 participants